package com.yusys.ticket;

public class SellTicket extends Thread {

    /**
     * 总数
     */
    private static int amount = 100;

    @Override
    public void run() {
        while (true) {
            // 卖完之后就退出
            if (amount <= 0) {
                System.out.println("售票结束...");
                break;
            }

            // 休眠
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            System.out.println("窗口 ：" + Thread.currentThread().getName() + "售出一张票，剩余票数：" + (--amount));
        }
    }
}
